<%= page_title "Request Deploys Report" %>

<section>
  <div class="csv-deploy-filters clearfix">
    <%= form_tag csv_exports_path, class: "form-horizontal" do %>
      <div class="form-group">
        <%= label_tag :start_date, "Start Date:", class: "col-lg-2 control-label" %>
        <div class="col-lg-2">
          <%= date_field_tag :start_date, Date.today.prev_year, id: "start-date", class: "form-control" %>
        </div>
      </div>

      <div class="form-group">
        <%= label_tag :end_date, "End Date:", class: "col-lg-2 control-label" %>
        <div class="col-lg-2">
          <%= date_field_tag :end_date, Date.today, id: "end-date", class: "form-control" %>
        </div>
      </div>

      <div class="form-group">
        <%= label_tag :production, "Production:", class: "col-lg-2 control-label" %>
        <div class="col-lg-2">
          <%= select_tag :production, options_for_select(['', 'Yes', 'No'], ''), class: "form-control" %>
        </div>
      </div>

      <div class="form-group">
        <%= label_tag :status, "Status:", class: "col-lg-2 control-label" %>
        <div class="col-lg-2">
          <%= select_tag :status, options_for_select([['All', 'all'], ['Succeeded', 'succeeded'], ['Failed', 'failed']], 'all'), class: "form-control" %>
        </div>
      </div>

      <div class="form-group">
        <%= label_tag :project, "Project", class: "col-lg-2 control-label" %>
        <% projects = [['', 0]] + Project.pluck(:name, :id) +
           Project.deleted.pluck(:name, :id).map { |name, id| ["(deleted) #{name}", id] } %>
        <div class="col-lg-4">
          <%= live_select_tag :project, options_for_select(projects, 0) %>
        </div>
      </div>

      <div class="form-group">
        <div class="col-lg-offset-2 col-lg-10 checkbox">
          <%= label_tag do %>
            <%= check_box_tag :bypassed, true %>
            Bypassed buddy check
          <% end %>
        </div>
      </div>

      <div class="form-group">
        <div class="col-lg-offset-2 col-lg-10">
          <%= submit_tag "Create Deploys CSV Report", class: 'btn btn-default' %>
        </div>
      </div>
      <%= hidden_field_tag :project_permalinks, params["project_permalinks"] %>
    <% end %>
  </div>
  <div class="clearfix">
    <hr />
    <div><strong>Other reports</strong></div>
    <div><%= link_to "Users Report", new_csv_export_path(type: :users) %></div>
  </div>
</section>
